Skip to content

Conversation

sweatybridge
Copy link
Contributor

@sweatybridge sweatybridge commented Aug 27, 2025

What kind of change does this PR introduce?

feature

What is the new behavior?

Allow custom timeout because type gen queries on large databases could take longer than the default 15s.

Additional context

Add any other context or screenshots.

@sweatybridge sweatybridge requested a review from a team as a code owner August 27, 2025 07:57
@coveralls
Copy link

Pull Request Test Coverage Report for Build 17260823135

Details

  • 24 of 32 (75.0%) changed or added relevant lines in 3 files are covered.
  • 9 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.02%) to 54.744%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/db/diff/migra.go 2 3 66.67%
cmd/gen.go 0 7 0.0%
Files with Coverage Reduction New Missed Lines %
internal/db/diff/migra.go 2 43.04%
internal/storage/rm/rm.go 2 80.61%
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 17259383467: -0.02%
Covered Lines: 6203
Relevant Lines: 11331

💛 - Coveralls

Copy link
Member

@avallete avallete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

It really shouldn’t take that much time though 🤔

If you have a reproducible example (a database schema) that triggers this issue, I’d be happy to create an issue on the postgres-meta side. There’s probably some performance bottleneck we could investigate and optimize in such cases.

@sweatybridge sweatybridge merged commit d9b9e0e into develop Aug 27, 2025
15 checks passed
@sweatybridge sweatybridge deleted the query-timeout branch August 27, 2025 08:56
@yilinjuang
Copy link

@avallete I have a supabase project that can reproduce the timeout. How can I share it with you privately?

Copy link
Member

avallete commented Sep 1, 2025

Hey ! Thank's for reaching out ! Yes I have. This allowed us to pinpoint that the cause of the issue was a bug in the introspection queries performed that postgres-meta, those only filter by schema/entity at the end of the query, constructing the CTE for all of the objects, before filtering out only the ones it needs.

I drafted a PR to adress this: supabase/postgres-meta#980

Which on my tests reduce typegen time from 22s+ to ~200ms. We'll try to roll that out ASAP.

@github-actions github-actions bot mentioned this pull request Sep 2, 2025
@yilinjuang
Copy link

Awesome! Yes this matches what we observed on our end. The more schemas we have the longer the generation takes even when we apply the schema filters. Look forward to the release.

@avallete
Copy link
Member

avallete commented Sep 3, 2025

Hey @yilinjuang

Just a quick update that the new version of postgres-meta has been released and should help with the typegen issue. It's not been released as the new default into the cli yet but you can try it early on by running:

echo "v0.91.6" > supabase/.temp/pgmeta-version

Before running your local stack, this should fix your local postgres-meta version to the one containing the fix. You should then be able to generate your types with:

npx supabase gen types --lang typescript --local  > database.generated.ts

Would love to hear if it solve your use case or any feedbacks.

@yilinjuang
Copy link

@avallete thanks it works! It now takes 15 seconds to generate. It used to be 10 times.

But I got another problem, using the latest cli v2.40.4 or v2.40.6, I cannot start supabase locally. Health check of postgrest failed. I filed another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants